<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['mobile'])){
		$params['mobile']=trim($_RQ['mobile']);
		$return['params']['mobile']=$_RQ['mobile'];
	}
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	$fields=array('id','name','mobile','remark','status','createtime','pid');
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_cmspinche_log',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
		
		$p=pdo_get('jy_cmspinche_list',array('id'=>$v['pid']),array('title','start','end','time','type'));
		
		$v['type']=$p['type'];
		$v['title']=$p['title'];
		
	}
	$return['type']=array('1'=>'拼车','2'=>'带客');
	$return['status']=array('0'=>'取消','1'=>'确认');
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'日志列表'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'title','title'=>'拼车标题','type'=>'string'),
			array('name'=>'type','title'=>'类型','type'=>'radio','options'=>'type'),
			array('name'=>'pid','title'=>'拼车id','type'=>'string'),
			array('name'=>'name','title'=>'参与人','type'=>'string'),
			array('name'=>'mobile','title'=>'参与人电话','type'=>'string'),
			array('name'=>'createtime','title'=>'参与时间','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		),
		),
		'search'=>array(
			array('name'=>'name','width'=>15,'title'=>'参与人','type'=>'string'),
			array('name'=>'mobile','width'=>15,'title'=>'参与人电话','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_cmspinche_log',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_cmspinche_log',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}
?>